﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Procedure = DeltaFlex.Data.ConsProcedures.Factura;

namespace DeltaFlex.Data
{
    public class Factura
    {
        public Factura()
        { }

        #region Inserts
        public static void InsertarFactura(int idFactura, int idClient, DateTime data, DateTime venciment, decimal total)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = Procedure.SP_INSERTAR_FACTURA;

            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDFACTURA, idFactura);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_IDCLIENT, idClient);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_DATA, data);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_VENCIMENT, venciment);
            cmd.Parameters.AddWithValue(Procedure.PARAMETRE_TOTAL, total);

            Operacions_BD.Insertar(cmd);
        }
        #endregion

        #region Update

        #endregion

        #region Selects
        public static IDataReader Cercar_NextIdFactura()
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = Procedure.SP_CERCAR_NEXT_IDFACTURA;
            cmd.CommandType = CommandType.StoredProcedure;

            return Operacions_BD.Reader(cmd);
        }
        #endregion
    }
}
